<template>
  <div class="vue-box sbot" style="width: 520px;">
    <!-- ------- 内容部分 ------- -->
    <div class="c-panel">
      <div class="c-title">密码变更</div>
      <el-form :inline="true" >
        <sa-item v-model="m.oldPwd" type="password" name="旧密码" br />
        <sa-item v-model="m.newPwd" type="password" name="新密码" br />
        <sa-item v-model="m.newPwd2" type="password" name="确认密码" br />
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  name: 'acc-password',
  data() {
    return {
      m: {
        oldPwd: '',
        newPwd: '',
        newPwd2: ''
      },
    }
  },
  methods: {
    // 提交
    ok: function () {
      let _this = this;
      // 表单校验
      let m = this.m;
      sa.checkNull(m.oldPwd, '请输入旧密码');
      sa.checkNull(m.newPwd && m.newPwd2, '请填写新密码');
      sa.check(m.newPwd !== m.newPwd2, '新密码两次输入不一致');
      sa.check(m.newPwd.length < 6, '新密码请不要低于六位数');
      // 开始变更
      sa.ajax('/sso/password/update', this.m, function () {
        sa.alert(res.msg, function () {
          sa.closeModel();
           // 变更密码重新登录、跳转到登录
           _this.$router.push(`/scs?redirect=${_this.$route.fullPath}`);
          // 清空TOKEN
          localStorage.clear()
        })
      },{type:'post'})
    },
  },
}
</script>

<style scoped>
>>>.c-item .c-label {
  width: 10em;
}

>>>.c-item .el-input__inner {
  width: 300px;
}
</style>
